/**
 * Created by lixiangcheng on 2017/6/14.
 */
/**
 * 传入所需的key，将返回你需要的value
 * @param sArgName
 * @returns {string}
 * @constructor
 */
function GetArgsFromHref(sArgName) {
    var sHref = window.location.href;
    var args = sHref.split("?");
    var retval = "";
    
    if (args[0] == sHref) /*参数为空*/
    {
        return retval;
        /*无需做任何处理*/
    }
    var str = args[1];
    args = str.split("&");
    for (var i = 0; i < args.length; i++) {
        str = args[i];
        var arg = str.split("=");
        if (arg.length <= 1) continue;
        if (arg[0] == sArgName) retval = arg[1];
    }
    console.log(sHref+"===="+sArgName+"="+retval);
    return retval;
}

var callHTTPRequestLogon = function(data) {
    var categoryID = 'Account';
    var funcID = 'Logon';
    // var data = "{'username':'ettmtt','password':'123456'}";
    var showMessage = true;
    javaHandler.callHTTPRequest(categoryID, funcID, data, true);
    // javaHandler.callHTTPRequest('Account','Logon',{'username':'ettmtt','password':'111111'},true);
};
var _callAjaxRequest = function(url, data, callback) {
    $.ajax({
        type : "POST",
        url : url,
        async : false, // 使用同步方式
        // 1 需要使用JSON.stringify 否则格式为 a=2&b=3&now=14...
        // 2 需要强制类型转换，否则格式为 {"a":"2","b":"3"}
        data : data,
        // contentType: "application/json; charset=utf-8",
        dataType : "json",
        crossDomain : true,
        success : callback,
        error : function(err) {
            //alert(JSON.stringify(err));
            alert("您当前网络信号差，请稍后再试！");
        }
    });
}

function guid() {
	  return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
	    var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
	    return v.toString(16);
	  });
	}

function timeFilter(secdons){  
    if (secdons<60){  
        var sec  
        sec = (secdons>0)?secdons + '秒':''  
        timeFormat = timeFormat + sec  
        return;  
    }  
    else if(secdons<3600){  
        var min  
        min = Math.floor(secdons/60)  
        //console.log(min)  
        timeFormat = timeFormat + min + '分钟'  
        timeFilter(secdons-min*60)  
    }  
    else{  
        var hour  
        hour = Math.floor(secdons/3600)  
        timeFormat = timeFormat + hour + '小时'  
        timeFilter(secdons-hour*3600)  
    }  
}
/*var secdons = 3921;
var timeFormat = '';
timeFilter(secdons)  
console.log(secdons)  
console.log(timeFormat)
*/
// 格式化秒数到时间格式
Number.prototype.formatTime=function(){
    // 计算
    var h=0,i=0,s=parseInt(this);
    if(s>60){
        i=parseInt(s/60);
        s=parseInt(s%60);
        if(i > 60) {
            h=parseInt(i/60);
            i = parseInt(i%60);
        }
    }
    // 补零
    var zero=function(v){
        return (v>>0)<10?"0"+v:v;
    };
    return [zero(h),zero(i),zero(s)].join(":");
};
//console.log(Number(3600*10+3921.7).formatTime());

//全局变量
var _global = {
    sendPost : "0",// 0-ajax;1-app;
    //serverHost : "http://192.168.0.104:80/shjy",
    //serverHost:"http://139.224.80.49/shjy",
    serverHost:"http://www.65376537.net/shjy",
    forgotUrl:"../login_forgot/forgot.html",
    custSignUrl:"../customer/sign/sign.html",
    custLoginUrl:"../customer/login.html",
    custIndexUrl:"../customer/index.html",
    custOrderUrl:"../customer/order/order_list.html",
    custNowOrderUrl:"../customer/order/input_order_now.html",
    custBookOrderUrl:"../customer/order/input_order.html",
    waitOrderUrl:"../customer/order/wait_order.html",
    orderListUrl:"../customer/order/order_list.html",
    driverLoginUrl:"../driver/login.html",
    driverIndexUrl:"../driver/index.html"

};

